home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Question on 'bubble sort'
- Date: 1 Apr 1996 10:53:11 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4jp8mnINNmq0@keats.ugrad.cs.ubc.ca>
- References: <4jieso$juc@lantana.singnet.com.sg> <828206958snz@genesis.demon.co.uk> <4jmv0d$t2p@news1.mnsinc.com>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4jmv0d$t2p@news1.mnsinc.com>,
- Szu-Wen Huang <huang@mnsinc.com> wrote:
- >Lawrence Kirby (fred@genesis.demon.co.uk) wrote:
- >: In article <4jieso$juc@lantana.singnet.com.sg>
- >: s8700055@singnet.com.sg "XY Xie" writes:
- >
- >: >I came across this sorting algorithm called 'bubble sort' in a book.
- >
- >: If the book doesn't explain why there is never a good reason to use bubble
- >: sort then I suggest you get another book.
- >
- >Sure there is. If I had 5 minutes to code something that will sort
- >10 numbers, bubblesort comes in real handy. If you've ever joined
- >a programming contest you'll know what I mean.
-
-
- It's also good for sorting a fixed number of points. Say I had to sort the
- three vertices of a triangle in order of increasing y coordinate. What you do
- is just compare the first two points, possibly swap, then the last two points,
- possibly swap and then compare the first two points again, possibly swapping.
-
- This is just a special case of the bubble sort and I have used it in polygon
- drawing code.
-
- The asymptotic complexity of algorithms matters little on any data set whose
- size is fixed in advance, especially when the size is small. The precise size
- at which the algorithm with better complexity surpasses the worse algorithm in
- performance depends on the constants introduced by the implementation.
- --
-
-